<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>商品管理</title>
 <script th:inline="javascript">
/*<![CDATA[*/

 function add(event, element) {
    event.preventDefault();
    var re = /^[0-9]*[1-9][0-9]*$/;
    var _id = $(element).attr("href").split("_")[0];
    var _multiple = $("#multiple" + _id).val();
    var _credit = $("#credit" + _id).val();
    var _creditPromotionId = $(element).attr("href").split("_")[1];
    var _viewState = $("#hidden_viewState").val();
     var _page = $(element).attr("href").split("_")[2];


//    alert("id"+_id);
//    alert("multiple"+_multiple);
//    alert("credit"+_credit);
//    alert("creditPromotionId"+_creditPromotionId);
//    alert("viewState"+_viewState);

    if ($("#div_goods_grid table tr th:contains('积分')").size() > 0) {
        if (!re.test(_credit)) {
            alert("请输入正确的积分");
            return;
        }
        if(_credit > 10000) {
             alert("积分不能超过10000");
            return;
        }
    }

    if ($("#div_goods_grid table tr th:contains('倍数')").size() > 0) {
        if (!re.test(_multiple)) {
            alert("请输入正确的倍数");
            return;
        }
        if (_multiple > 10) {
            alert("倍数不能超过10");
            return;
        }
    }

    $.ajax({
          url: "/promotion/creditpromotiongoods/ajaxSave",
          cache: false,
          type:"post",
          data:{ajaxId: _id, ajaxMultiple: _multiple, ajaxCredit: _credit, ajaxCreditPromotionId: _creditPromotionId, viewState: _viewState,page:_page},
          success:function(result) {	//回调函数，result，返回值
              $("#div_goods_grid").html(result);
          }
     });
}



	
/*]]>*/
</script>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{'/promotion/creditpromotiongoods/index/'+${creditPromotionId}}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="form">
					<h4 class="form-section">商品信息</h4>
					<input id="hidden_viewState" type="hidden" name="viewState" th:value="${viewState}"/>
                <div class="form-body">
					<div class="col-md-15 col-sm-13">
						<form class="form-inline" th:action="@{'/promotion/creditpromotiongoods/list/'+${creditPromotionId}}"  th:object="${goodsSearch}"  method="post">
							<div class="form-group">
					            <select id="goodsBrandsId" name="goodsBrandsId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有品牌</option>
					                <option th:each="eachValue : ${brands}" th:field="*{goodsBrandsId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>	
					            <input type="hidden" id="hidden_goodsBrandsId" th:value="${goodsBrandsId}" />												
						</div>
							
							<div class="form-group">
					            <select id="goodsCategoryId" name="goodsCategoryId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有分类</option>
					                <option th:each="eachValue : ${categorys}" th:field="*{goodsCategoryId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>
					            <input type="hidden" id="hidden_goodsCategoryId" th:value="${goodsCategoryId}" />														
							</div>
		
							
							<div class="form-group">
							<label class="sr-only" for="keyword">keyword</label>
								<input type="text" name="keyword" style="width:80px;" th:field="*{keyword}" placeholder="关键字"  id="keyword" class="form-control" />
							</div>
	
							
							
							<button type="submit" id="bt_search" name="bt_search" class="btn green">
								<i class="fa  fa-search"></i>
							</button>
						</form>
					</div>
					
					
					</div>
					<div id = "div_goods_grid" th:include="promotion/creditpromotiongoods/goods_table">
		
					</div>
			</div>
		</div>
	</div>
</div>	
</body>
</html>
